import axios from 'axios'
import { router } from '@/route/router';
const env = import.meta.env
const host = env.DEV ? '/api' : env.VITE_HTTP_URL
export async function httppost(portUrl: PortUrl, data: any): Promise<any> {
  return axios.post(`${host}${portUrl}`, data, {
    headers: {
      "Content-Type": "application/json"
    }
  }).catch((err) => {
    console.log(err.response.data, 'err request');
    if (err.response.data.statusCode === 401) {
      router.replace({ name: 'NotImportant' })
    }
    return Promise.reject(err.response)
  })
}

export enum PortUrl {
  register = '/auth/register',
  login = '/auth/login'
}

export type Response = {

}